package jp.eisbahn.mgapi.util;

/**
 * The utility class about a string operation.
 * @author Yoichiro Tanaka
 */
public final class StringUtils {

    /**
     * Initialize this instance.
     */
    private StringUtils() {
        super();
    }

    /**
     * Join each string.
     * @param array The array which has each string.
     * @param delimiter The character as the delimiter.
     * @return The joined string.
     */
    public static String join(final String[] array, final String delimiter) {
        if (array == null) {
            return null;
        }
        StringBuilder sb = new StringBuilder();
        boolean first = true;
        for (int i = 0; i < array.length; i++) {
            if (first) {
                first = false;
            } else {
                sb.append(delimiter);
            }
            sb.append(array[i]);
        }
        return sb.toString();
    }

}
